﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SiteRequireLogin.Master" AutoEventWireup="true" CodeBehind="Chenh-Lech-Gia-Ban.aspx.cs" Inherits="TranTekBE.Price.Chenh_Lech_Gia_Ban" EnableEventValidation="false" %>

<%@ Register Src="~/NhaThuoc/MenuNhaThuoc.ascx" TagPrefix="uc1" TagName="MenuNhaThuoc" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="assets/css/main-style.css" rel="stylesheet" />
    <link href="assets/css/style.css" rel="stylesheet" />
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <link href="assets/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="assets/plugins/timeline/timeline.css" rel="stylesheet" />
    <link href="assets/plugins/social-buttons/social-buttons.css" rel="stylesheet" />
    <script src="assets/plugins/pace/pace.js"></script>
    <link href="assets/plugins/bootstrap/bootstrap.css" rel="stylesheet" />
    <script src="assets/plugins/bootstrap/bootstrap.js"></script>
    <script src="assets/plugins/bootstrap/bootstrap.min.js"></script>
    <script src="assets/plugins/dataTables/jquery.dataTables.js"></script>
    <link href="assets/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <script src="assets/plugins/dataTables/dataTables.bootstrap.js"></script>
    <script src="assets/plugins/flot/excanvas.min.js"></script>
    <script src="assets/plugins/flot/jquery.flot.js"></script>
    <script src="assets/plugins/flot/jquery.flot.pie.js"></script>
    <script src="assets/plugins/flot/jquery.flot.resize.js"></script>
    <script src="assets/plugins/flot/jquery.flot.tooltip.min.js"></script>
    <script src="assets/plugins/morris/raphael-2.1.0.min.js"></script>
    <link href="assets/plugins/morris/morris-0.4.3.min.css" rel="stylesheet" />
    <script src="assets/plugins/morris/morris.js"></script>
    <script src="assets/plugins/metisMenu/jquery.metisMenu.js"></script>
    <link href="assets/plugins/pace/pace-theme-big-counter.css" rel="stylesheet" />
    <script src="assets/scripts/dashboard-demo.js"></script>
    <script src="assets/scripts/flot-demo.js"></script>
    <script src="assets/scripts/morris-demo.js"></script>
    <script src="assets/scripts/siminta.js"></script>



    <script type="text/javascript" src="../Scripts/jsLib.js"></script>
    <script type="text/javascript">
        function LoadJS() {

            $("#<%=txt_thoi_gian_loc.ClientID %>").datepicker(
                    {
                        changeMonth: true,
                        changeYear: true,
                        showButtonPanel: true,
                        dateFormat: "mm/dd/yy",
                        beforeShow: function () {
                            $(".ui-datepicker").css('font-size', 12)
                        }
                    }
                    );

        }
    </script>
    <!------------------------------>
    <!--script auto complete ddl !-->
    <!------------------------------>

    <style>
        .ui-button {
            margin-left: -1px;
        }

        .ui-button-icon-only .ui-button-text {
            padding: 0.35em;
        }

        .ui-autocomplete-input {
            margin: 0;
            padding: 0.48em 0 0.47em 0.45em;
            font: 10px;
        }
    </style>
    <!------------------------------>
    <!--End script auto complete ddl !-->
    <!------------------------------>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContent" runat="server">


    <div id="wrappermiss">
        <div id="page-wrapper">
            <!-- page header -->
            <uc1:MenuNhaThuoc runat="server" ID="MenuNhaThuoc" />
            <div class="col-lg-12">
                <h3 class="page-header">Báo cáo sản phẩm có mức chênh lệch giá bán thị trường</h3>
            </div>
            <!--end page header -->

            <div class="col-lg-12">
                <!-- Form Elements -->
                <div class="panel panel-default">
                    <div class="panel-heading">
                        Điền đầy đủ các thông tin
                    </div>
                    <asp:Literal ID="ok" runat="server"></asp:Literal>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">

                                <form role="form">
                                    <div class="form-group">
                                        <%--<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />--%>
                                        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
                                        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>

                                        <asp:Literal ID="status" runat="server"></asp:Literal>
                                        <script type="text/javascript">
                                            $(function () {
                                                $('.form-control').autocomplete({
                                                    source: function (request, response) {
                                                        $.ajax({
                                                            url: "Chenh-Lech-Gia-Ban.aspx/getnameserver",
                                                            data: "{ 'value': '" + request.term + "' }",
                                                            dataType: "json",
                                                            type: "POST",
                                                            contentType: "application/json; charset=utf-8",
                                                            dataFilter: function (data) { return data; },
                                                            success: function (data) {
                                                                response(

                                                                    $.map(data.d, function (item) {
                                                                        return {
                                                                            value: item.label,
                                                                            label: item.label,
                                                                            id: item.value

                                                                        }
                                                                    }))

                                                            }

                                                        });
                                                    },
                                                    select: function (event, ui) {

                                                        $("#idsp").val(ui.item.id);
                                                        $("#loc-idsp").val(ui.item.id);
                                                        $.ajax({
                                                            url: "Chenh-Lech-Gia-Ban.aspx/getDonvitinh",
                                                            data: "{ 'value': '" + ui.item.id + "' }",
                                                            dataType: "json",
                                                            type: "POST",
                                                            contentType: "application/json; charset=utf-8",
                                                            dataFilter: function (data) { return data; },
                                                            success: function (data) {
                                                                $("#ctl00_BodyContent_Droplist_DVT").html('');
                                                                for (var i = 0; i < data.d.length; i++) {
                                                                    $("#ctl00_BodyContent_Droplist_DVT").append('<option value=' + data.d[i] + '>' + data.d[i] + '</option>');
                                                                }
                                                            }

                                                        });

                                                    },
                                                    minLength: 2
                                                });

                                            });
                                        </script>
                                        <a style="text-decoration: none">Tên nhân viên: <b>
                                            <asp:Label runat="server" ID="employee" Enabled="false"></asp:Label></b></a>
                                        <a style="margin-left: 50px; text-decoration: none">Nhà thuốc: <b>
                                            <asp:Label runat="server" ID="lbStore" Enabled="false"></asp:Label></b></a>
                                        <br />
                                        <br />
                                        <b style="color: red">*</b>(Bắt buộc nhập)<br />
                                        <br />
                                        <asp:UpdatePanel ID="UpdatePanel" runat="server">
                                            <ContentTemplate>
                                                <asp:TextBox ID="tbAuto" Height="19px" class="form-control" runat="server" placeholder="Nhập tên thuốc (Ví dụ: Panadol)" AutoPostBack="false"></asp:TextBox>
                                                <input type="hidden" value="" id="idsp" name="idsp" />

                                                <br />
                                                <br />

                                                <select id="ctl00_BodyContent_Droplist_DVT" name="dvt" style="height: 35px; width: 200px"></select><b style="color: red">*</b>

                                                <br />
                                                <br />

                                                <asp:DropDownList ID="Droplist_GiaCH" runat="server" Height="35" Width="200px"></asp:DropDownList><b style="color: red">*</b>
                                                <br />
                                                <br />

                                                <asp:TextBox ID="txtGiaTT" runat="server" placeholder="Nhập giá thị trường" Height="30" Width="200px"></asp:TextBox>(vnđ) <b style="color: red">*</b>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                        <br />
                                        <br />
                                        <label>Ghi chú:<b style="color: red">*</b></label>
                                        <asp:TextBox ID="txtnote" class="form-control" runat="server" Columns="3" TextMode="MultiLine"></asp:TextBox>
                                        <asp:Button ID="submit" class="btn btn-primary" runat="server" Text="Thêm sản phẩm" OnClick="submit_Click" />
                                    </div>
                                </form>
                            </div>




                        </div>
                    </div>
                </div>
                <!-- End Form Elements -->
                <!-- -->
                <div class="panel panel-default">
                    <div class="panel-heading"><b>Sản phẩm chênh lệch giá bán</b> </div>
                    <!--Lọc-->
                    <div style="border: 1px solid #CCC; padding-top: 10px; padding-left: 10px; margin-bottom: 10px">
                        <div style="float: left; margin-right: 20px; width: 250px">
                            <asp:TextBox ID="txtTenSP" Height="19px" class="form-control" runat="server" placeholder="Nhập tên thuốc (Ví dụ: Panadol)" AutoPostBack="false" OnTextChanged="txtTenSP_TextChanged"></asp:TextBox>
                            <input type="hidden" value="" id="loc-idsp" name="loc-idsp" />
                        </div>
                        <div class="demo" style="width: 250px; float: left;">
                            <div class="ui-widget">
                                <asp:DropDownList ID="droplist_loc_User" runat="server" Height="35px" placeholder="Chọn tên nhân viên" OnSelectedIndexChanged="droplist_loc_User_SelectedIndexChanged">
                                </asp:DropDownList>
                            </div>
                            <button id="toggleTenNV" style="display: none">Show underlying select</button>
                        </div>

                        <asp:DropDownList ID="droplist_cua_hang_loc_kq" Style="height: 34px; margin-left: -30px; margin-top: 0px;" runat="server" OnSelectedIndexChanged="droplist_cua_hang_loc_kq_SelectedIndexChanged">
                        </asp:DropDownList>

                        <asp:TextBox ID="txt_thoi_gian_loc" Style="height: 23px; width: 195px; margin-top: 0px;" runat="server" Width="195px" Height="30px" placeholder="Chọn ngày" OnTextChanged="txt_thoi_gian_loc_TextChanged"></asp:TextBox>

                        <asp:Button ID="btnLoc" runat="server" Text="LỌC" OnClick="btnLoc_Click" Style="width: 50px; height: 30px; margin-top: 0px; margin-left: 42px" />
                    </div>
                    <!--Lọc-->
                    <!--Table-->
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>STT</th>
                                        <th>Tên thuốc</th>
                                        <th>Mã thuốc</th>
                                        <th>Chênh lệch </th>
                                        <th>Người gửi</th>
                                        <th>Cửa hàng</th>
                                        <th>Thời gian</th>
                                        <th>Ghi chú</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <asp:Repeater ID="rpSanPham" runat="server">
                                        <ItemTemplate>
                                            <tr style="<%# ThuVien.FunctionsUtils.CSS_RowInTable(Container.ItemIndex,"#FFFFE0","#D7E3F2") %>">
                                                <td class="tdGrid tdCenterM"><%# Container.ItemIndex + 1 %></td>
                                                <td style="width: 150px" class="tdGrid tdCenterM"><%# Eval("TenThuoc") %></td>
                                                <td class="tdGrid tdCenterM"><%# Eval("MaPOS") %></td>
                                                <td class="tdGrid tdCenterM"><%# ThuVien.FunctionsUtils.ConvertMoneyVND(Eval("ChenhLech")) %> vnđ</td>
                                                <td class="tdGrid tdCenterM"><%# Eval("NguoiGui") %></td>
                                                <td class="tdGrid tdCenterM"><%# Eval("CuaHang") %></td>
                                                <td class="tdGrid tdCenterM"><%# Eval("ThoiGianGui") %></td>
                                                <td style="width: 150px" class="tdGrid tdCenterM"><%# Eval("GhiChu") %></td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                    <!--Phân trang-->
                                    <div style="overflow: hidden">
                                        <asp:Repeater ID="rptPages" runat="server"
                                            OnItemCommand="rptPages_ItemCommandSP">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="btnPage"
                                                    Style="padding: 1px 3px; margin: 1px; background: #ccc; border: solid 1px #666; font: 8pt tahoma;"
                                                    CommandName="Page" CommandArgument="<%# Container.DataItem %>"
                                                    runat="server"><%# Container.DataItem %>
                                                </asp:LinkButton>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </div>
                                    <!--Phân trang-->
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!--Table-->

                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        //-----------------------------------------------
        //script auto complete ddl
        //-----------------------------------------------
        function optionSelected(selectedValue) {
            document.title = selectedValue;
        }

        (function ($) {
            $.widget("ui.combobox", {
                _create: function () {
                    var self = this,
                               select = this.element.hide(),
                               selected = select.children(":selected"),
                               value = selected.val() ? selected.text() : "";
                    var input = this.input = $("<input placeholder='Chọn tên nhân viên'>")
                               .insertAfter(select)
                               .val(value)
                               .autocomplete({
                                   delay: 0,
                                   minLength: 0,
                                   source: function (request, response) {
                                       var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
                                       response(select.children("option").map(function () {
                                           var text = $(this).text();
                                           if (this.value && (!request.term || matcher.test(text)))
                                               return {
                                                   label: text.replace(
                                                                        new RegExp(
                                                                               "(?![^&;]+;)(?!<[^<>]*)(" +
                                                                               $.ui.autocomplete.escapeRegex(request.term) +
                                                                               ")(?![^<>]*>)(?![^&;]+;)", "gi"
                                                                        ), "$1"),
                                                   value: text,
                                                   option: this
                                               };
                                       }));
                                   },
                                   select: function (event, ui) {
                                       ui.item.option.selected = true;
                                       self._trigger("selected", event, {
                                           item: ui.item.option
                                       });
                                       //JK
                                       optionSelected(ui.item.option.value);

                                   },
                                   change: function (event, ui) {
                                       if (!ui.item) {
                                           var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"),
                                                           valid = false;
                                           select.children("option").each(function () {
                                               if ($(this).text().match(matcher)) {
                                                   this.selected = valid = true;
                                                   return false;
                                               }
                                           });
                                           if (!valid) {
                                               // remove invalid value, as it didn't match anything
                                               $(this).val("");
                                               select.val("");
                                               input.data("autocomplete").term = "";
                                               return false;
                                           }
                                       }
                                   }
                               })
                               .addClass("ui-widget ui-widget-content ui-corner-left");

                    input.data("autocomplete")._renderItem = function (ul, item) {
                        return $("<li></li>")
                                      .data("item.autocomplete", item)
                                      .append("<a>" + item.label + "</a>")
                                       .appendTo(ul);
                    };


                },

                destroy: function () {
                    this.input.remove();
                    this.button.remove();
                    this.element.show();
                    $.Widget.prototype.destroy.call(this);
                }
            });
        })(jQuery);

        $(function () {

            $("#<%= droplist_loc_User.ClientID%>").combobox();

            $("#toggleTenNV").click(function () {
            });
        });

        //-----------------------------------------------
        //End script auto complete ddl
        //-----------------------------------------------

    </script>
</asp:Content>
